#include <iostream>
#include <string>

using namespace std;
string version1(const string &str1, const string &str2);
const string & version2(string &str1, const string &str2);//have side effect
const string & version3(string &str1, const string &str2);//bad design

int main(int argc, const char * argv[])
{
	string input;
	string result;
	
	cout << "Enter a string : ";
	getline(cin, input);
	
	string copy = input;
	
	cout << "The string you have enterd is " << input << endl;
	
	result = version1(input, "***version1***");
	cout << "Your enhanced string  is " << result << endl;
	cout << "Your original string is " << input << endl;
	
	result = version2(input, "***version2***");
	cout << "Your enhanced string  is " << result << endl;
	cout << "Your original string is " << input << endl;
	
	input = copy;
	result = version3(input, "***version3***");
	cout << "Your enhanced string  is " << result << endl;
	cout << "Your original string is " << input << endl;
	
	return 0;
}

string version1(const string &str1, const string &str2)
{
	string temp;
	temp = str1 + str2;
	return temp;
}

const string & version2(string &str1, const string &str2)
{
	str1 = str1 + str2;
	return str1;
}

const string & version3(string &str1, const string &str2)
{
	string temp;
	temp = str1 + str2;
	return temp;
}